﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace GameOfLife
{
	class Program
	{
		static void Main(string[] args)
		{
			Console.OutputEncoding = UTF8Encoding.UTF8;
			Console.BackgroundColor = ConsoleColor.Blue;
			Console.Clear();
			int boardSize = int.Parse(Console.ReadLine());
			GameOfLifeSimulator simulator = new GameOfLifeSimulator(boardSize);

			for (int i = 0; i < boardSize; i++)
			{
				char[] input = Console.ReadLine().ToArray();
				for (int j = 0; j < boardSize; j++)
				{
					simulator.Board[i, j] = (CellState) input[j];
				}
			}

			Console.WriteLine();
			Console.WriteLine();

			while (true)
			{ 
				Thread.Sleep(1000);
				//ConsoleKeyInfo key = Console.ReadKey(true);
				simulator.Simulate();
				Console.Clear();

				Console.WriteLine(simulator);
			}
		}
	}
}
